<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>华胜后台管理</title>
    <link rel="stylesheet" type="text/css" href="css/unified.css">
    <script src="plugins/layui/layui.js"></script>

    <style type="text/css">
        .searchform span{margin-left: 10px}
        .layui-table-view .layui-table td, .layui-table-view .layui-table th{padding: 0}
    </style>
</head>
<body>

    <div class="breadcrumbnav">
        <span class="layui-breadcrumb " lay-separator="·">
          <a ><cite>首页</cite></a>
          <a ><cite>委托加工管理</cite></a>

        </span>
    </div>
    <div class="kit-doc">
        <!-- 标题 -->
        <div class="kit-doc-title">
            <fieldset>
                <legend> <a name="blockquote">加工</a>
                </legend>
            </fieldset>
        </div>
        <!-- 标题 end-->
        
        <!-- 概述 -->
         <div class="boderbox">
       		<div class="rowtop">
	            <button class="layui-btn addbtn openwinbtn" data-method="addmang">添加+</button>
            </div>
             <div class="layui-tab-content notab">
                <div class="layui-tab-item layui-show">
                    <table class="layui-table " lay-filter="table100" id="EGtable"></table>
                </div>
              </div>
		</div>
		
		<script id="addBox" type="text/html">
			<div class=" layui-layer-wrap">
                <form class="layui-form layui-form-pane" action="" id="addform" >
                    
                    <div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
                    	 <div class="layui-form-item">
						    <label class="layui-form-label">委托编号</label>
						    <div class="layui-input-block">
						      <input type="number" name="entrustNumber" autocomplete="off"     placeholder="请输入数字编号" class="layui-input">
						    </div>
						  </div>
                    </div>
                   	<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
                    <div class="layui-form-item">
					    <label class="layui-form-label">产品名称</label>
					    <div class="layui-input-block">
					      <input type="text" name="productName" autocomplete="off"     placeholder="请输入产品名称" class="layui-input">
					    </div>
					</div>
					</div>
                   	<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
                    <div class="layui-form-item">
					    <label class="layui-form-label">产品代号</label>
					    <div class="layui-input-block">
					      <input type="text" name="productCode" autocomplete="off"     placeholder="" class="layui-input">
					    </div>
					</div>
					</div>
                   	<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
					<div class="layui-form-item">
					    <label class="layui-form-label">单位</label>
					    <div class="layui-input-block">
					      <input type="text" name="unit" autocomplete="off"     placeholder="" class="layui-input">
					      
					    </div>
					</div>
					</div>
                   	<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
					<div class="layui-form-item">
					    <label class="layui-form-label">生产编号</label>
					    <div class="layui-input-block">
					      <input type="number" name="productionNumber" autocomplete="off"  placeholder="请输入数字编号"   class="layui-input">
					    </div>
					</div>
					</div>
                   	<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
					<div class="layui-form-item">
					    <label class="layui-form-label">辅助号码</label>
					    <div class="layui-input-block">
					      <input type="number" name="auxiliaryNumber" autocomplete="off"  placeholder="请输入数字编号" class="layui-input">
					    </div>
					</div>
					</div>
                   	<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
					<div class="layui-form-item">
					    <label class="layui-form-label">供应商电话</label>
					    <div class="layui-input-block">
					      <input type="number" name="supplierPhone" autocomplete="off"  placeholder="" class="layui-input">
					    </div>
					</div>
					</div>
                   	<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
					<div class="layui-form-item">
					    <label class="layui-form-label">单价</label>
					    <div class="layui-input-block">
					      <input type="number" name="unitPrice" min="0"  autocomplete="off"     placeholder="￥" class="layui-input">
					    </div>
					</div>
					</div>
                   	<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
                    <div class="layui-form-item">
                          <label class="layui-form-label">金额</label>
                          <div class="layui-input-block">
                            <input type="number" name="aggregateAmount"   min="0"  autocomplete="off" class="layui-input" placeholder="￥" >
                          </div>
                    </div>
                    </div>
                   	<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
                    <div class="layui-form-item">
                          <label class="layui-form-label">评论</label>
                          <div class="layui-input-block">
                            <input type="text" name="remarks"   autocomplete="off" class="layui-input" placeholder="" >
                          </div>
                    </div>
                    </div>
                   	<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
                    <div class="layui-form-item">
                          <label class="layui-form-label">商品id</label>
                          <div class="layui-input-block">
                            <input type="number" name="commodityId" autocomplete="off" class="layui-input" placeholder="" >
                          </div>
                    </div>
                    </div>
                   	
                   	<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
                    <div class="layui-form-item">
                          <label class="layui-form-label">商品数量</label>
                          <div class="layui-input-block">
                            <input type="number" name="commodityNumber" autocomplete="off" class="layui-input" placeholder="" >
                          </div>
                    </div>
                    </div>
                   	<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
                    <div class="layui-form-item">
                          <label class="layui-form-label">条形码</label>
                          <div class="layui-input-block">
                            <input type="number" name="barCode" autocomplete="off" class="layui-input" placeholder="" >
                          </div>
                    </div>
                    </div>
                   	<!--<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
                    <div class="layui-form-item">
                          <label class="layui-form-label">创建id</label>
                          <div class="layui-input-block">
                            <input type="text" name="createId"    autocomplete="off" class="layui-input" placeholder="" >
                          </div>
                    </div>
                    </div>
                   	<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
                    <div class="layui-form-item">
                          <label class="layui-form-label">创建时间</label>
                          <div class="layui-input-block">
                            <input type="text" name="createTime"    autocomplete="off" class="layui-input" placeholder="" >
                          </div>
                    </div>
                    </div>-->
                   	<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
                    <div class="layui-form-item">
                          <label class="layui-form-label">委托编号</label>
                          <div class="layui-input-block">
                            <input type="number" name="entrustMerchantName"   autocomplete="off" class="layui-input" placeholder=""  >
                          </div>
                    </div>
					</div>
						<!--<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
                    <div class="layui-form-item">
                          <label class="layui-form-label">位置id</label>
                          <div class="layui-input-block">
                            <input type="text" name="locationId"    autocomplete="off" class="layui-input" placeholder=""  >
                          </div>
                    </div>
					</div>-->
						<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
                    <div class="layui-form-item">
                          <label class="layui-form-label">仓库号</label>
                          <div class="layui-input-block">
                            <input type="number" name="warehouseNumber"    autocomplete="off" class="layui-input" placeholder=""  >
                          </div>
                    </div>
					</div>
					
					<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
                    <div class="layui-form-item">
                          <label class="layui-form-label">委托时间</label>
                          <div class="layui-input-block">
                            <input type="text" name="entrustTime" id="entrustTime" lay-verify="date" autocomplete="off" class="layui-input" placeholder="yyyy-MM-dd HH:mm" >
                          </div>
                    </div>
        
					</div>
					<!--<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
                    <div class="layui-form-item">
                          <label class="layui-form-label">上传时间</label>
                          <div class="layui-input-block">
                            <input type="text" name="updareTime"    autocomplete="off" class="layui-input" placeholder=""  >
                          </div>
                    </div>
					</div>-->
						<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
                    <div class="layui-form-item">
                          <label class="layui-form-label">摘要信息</label>
                          <div class="layui-input-block">
                            <input type="text" name="abstractInfo"    autocomplete="off" class="layui-input" placeholder=""  >
                          </div>
                    </div>
					</div>
					<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
                    <div class="layui-form-item">
                          <label class="layui-form-label">运营商id</label>
                          <div class="layui-input-block">
                            <input type="number" name="operatorId"    autocomplete="off" class="layui-input" placeholder=""  >
                          </div>
                    </div>
					</div>
					<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
                    <div class="layui-form-item">
                          <label class="layui-form-label">状态</label>
                          <div class="layui-input-block">
                            <input type="number" name="state"    autocomplete="off" class="layui-input" placeholder="1为成功0为失败" max="1" min="0" >
                          </div>
                    </div>
					</div>
                </form>
            </div>
		</script><!--addBox结束-->
           

            <script src="js/jquery-3.2.1.min.js"></script>
            <script type="text/javascript" src="js/allajax.js"></script>
            <script>

            layui.use(['layer', 'form', 'element','table','laypage', 'laydate'], function(){
              var layer = layui.layer
              ,form = layui.form
              ,element = layui.element
              ,table = layui.table
              ,laypage = layui.laypage,laydate = layui.laydate;
				var tableArray = new Array();
				
				EGListFn(1 ,100 );
				function EGListFn(curr ,limit ){
					AjaxPostFn('system/material/out/select?page='+curr+'&pagesize='+limit, "{}", function(jsonData) {
						$.each(jsonData.pageInfo.list, function(i, obj) {
							console.log(obj.entrustTime)
							tableArray.push({
//								例子"id":obj.id,
								"id": obj.id,
								"operation": "<a class='layui-btn layui-bg-red ' lay-event='DelThis'>删除</a>",
						        "entrustNumber": obj.entrustNumber,
						        "productName": obj.productName,
						        "productCode": obj.productCode,
						        "unit": obj.unit,
						        "productionNumber": obj.productionNumber,
						        "auxiliaryNumber": obj.auxiliaryNumber,
						        "unitPrice": obj.unitPrice,
						        "aggregateAmount": obj.aggregateAmount,
						        "remarks": obj.remarks,
						        "commodityId": obj.commodityId,
						        "commodityNumber": obj.commodityNumber,
						        "barCode": obj.barCode,
						        "createId": obj.createId,
						        "createTime": getMyDate(obj.createTime),
						        "entrustMerchantName": obj.entrustMerchantName,
						        "locationId": obj.locationId,
						        "warehouseNumber": obj.warehouseNumber,
						        "entrustTime": getMyDate(obj.entrustTime),
						        "updareTime": getMyDate(obj.updareTime),
						        "abstractInfo": obj.abstractInfo,
						        "operatorId": obj.operatorId,
						        "state": obj.state
								
							});
						})
						
						//展示已知数据
						table.render({
							elem: '#EGtable',
							cols: [
								[ //标题栏
									{field: 'operation',width: 100,title: '操作'},
									{ field: 'id', minWidth: '0%', width: '0%',type: 'space',style: 'display:none' },
									{field: 'entrustNumber',width: 100,title: '委托编号'},
									{field: 'productName',width: 100,title: '产品名称'},
									{field: 'productCode',width: 100,title: '产品代号'},
									{field: 'unit',width: 100,title: '单位'},
									{field: 'productionNumber',width: 100,title: '生产编号'},
									{field: 'auxiliaryNumber',width: 100,title: '辅助号码'},
									{field: 'unitPrice',width: 100,title: '单价'},
									{field: 'aggregateAmount',width: 100,title: '金额'},
									{field: 'remarks',width: 100,title: '评论'},
									{field: 'commodityId',width: 100,title: '商品id'},
									{field: 'commodityNumber',width: 100,title: '商品数量'},
									{field: 'barCode',width: 100,title: '条形码'},
									{field: 'createId',width: 100,title: '创建id'},
									{field: 'createTime',width: 200,title: '创建时间'},
									{field: 'entrustMerchantName',width: 100,title: '委托商名'},
									{field: 'locationId',width: 100,title: '位置id'},
									{field: 'warehouseNumber',width: 100,title: '仓库号'},
									{field: 'entrustTime',width: 200,title: '委托时间'},
									{field: 'updareTime',width: 200,title: '上传时间'},
									{field: 'abstractInfo',width: 100,title: '摘要信息'},
									{field: 'operatorId',width: 100,title: '运营商id'},
									{field: 'state',width: 100,title: '状态'},
								]
							],
							data: tableArray,
							size: 'lg',
							even: true,
							page: true, //是否显示分页
							height:'full-300',
							done: function(){
//								 laypage.render({
//								    elem: 'layui-table-page1' //注意，这里的 test1 是 ID，不用加 # 号
//								    ,count: jsonData.pageInfo.total//数据总数，从服务端得到
//								    
//								    ,jump: function(obj, first){
//									    //obj包含了当前分页的所有参数，比如：
//									    console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
//									    console.log(obj.limit); //得到每页显示的条数
//									   
//									    //首次不执行
//									    if(!first){
//									      //do something
//									      EGListFn(obj.curr,obj.limit);
//									    }
//									  }
//								  });
							}
						});//数据渲染结束

					})
					
				}//EGListFn函数结束
				table.on('tool(table100)', function(obj){ 
                  var data = obj.data; //获得当前行数据
                  var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
                  var tr = obj.tr; //获得当前行 tr 的DOM对象
                 
                  if(layEvent === 'DelThis'){ //删除
                  	layer.confirm('是否删除该条信息', function(index) {
						AjaxPostFn('system/entrust/deletebyid', "{'id':'" + data.id + "'}", function(jsonData) {
							if(jsonData.htmlState.status == 200) {
								layer.msg("删除成功");

							} else {}
						})
						obj.del();
						layer.close(index);

					});
                		
                  }
              	})
				 $('.openwinbtn').on('click', function() {
                    var othis = $(this),
                        method = othis.data('method');
                    active[method] ? active[method].call(this, othis) : '';
                });
				var active = {
//                 弹出框事件
                    addmang:function(){
                        
						var addindex = layer.open({
						  type: 2,
						  title:"委托加工领料单录入",
						  area: ['100%', '100%'],
						  maxmin: true,
						  shade: 0,
						  content: 'Entrust_in.html'
						});
                    }
                }

            });     

            </script>

    </div>
</body>
</html>